import { _decorator, Component, Node } from "cc";
import DataManager from "../Runtime/DataManager";
const { ccclass, property } = _decorator;
@ccclass("GameManager")
export class GameManager extends Component {
  private static instance: GameManager;

  @property(Node)
  player: Node = null;
  @property(Node)
  bulletParent: Node = null;
  onLoad() {
    //GameManager.player = this.node.parent.getChildByName("Player");
    // if (!GameManager.instance) {
    //   GameManager.instance = this;
    //   this.init();
    // } else {
    //   this.destroy();
    // }
    this.init();
  }

  public static getInstance(): GameManager {
    if (!GameManager.instance) {
      throw new Error("GameManager instance not initialized");
    }
    return GameManager.instance;
  }
  //初始化
  init() {
    DataManager.Instance.player = this.player;
    DataManager.Instance.bulletParent = this.bulletParent;
  }
}
